package 多线程.复习.线程池;

import java.util.concurrent.*;

public class ExecutePoolTest {
    public static void main(String[] args) {
        //创建固定大小线程池
        ExecutorService pool1 = Executors.newFixedThreadPool(10);
        //创建定时线程池
        ScheduledExecutorService pool2 = Executors.newScheduledThreadPool(10);
//        //创建可变大小线程池
        ExecutorService pool3 = Executors.newCachedThreadPool();
//        //创建只有一个线程的线程池
        ExecutorService pool4 = Executors.newSingleThreadExecutor();
        pool1.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName());
            }
        });
        pool1.shutdown();
        pool2.schedule(new Runnable() {
            @Override
            public void run() {
                System.out.println("三秒后打印"+123);
            }
        },3000,TimeUnit.MILLISECONDS);
        pool2.shutdown();
    }
}
